how to iterate over object and dynamically assign values to keys